﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartGrid.NET.WPFUtils.Converters
{
    public class EnumConverter<E> :
        EnumConverterBase<E, EnumConverter<E>>
        where E : struct
    {
        protected override E? Convert(string vl)
        {
            var e = _MapString2Enum[vl];

            return e;
        }

        protected override string[] Convert(E[] enums)
        {
            var list = new List<string>();

            foreach (var e in enums)
            {
                list.Add(_MapEnum2String[e]);
            }

            return list.ToArray();
        }

        protected override string Convert(E vl)
        {
            var e = _MapEnum2String[vl];

            return e;
        }
    }
}
